

package fluebot;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Aksel Kvitberg
 */
public class IO {

	public static String readAllText(String filename){
		File f = new File(filename);
		return readAllText(f);
	}

	public static String readAllText(File file){
		try {
			StringBuffer strBfr = new StringBuffer();
			FileInputStream fis = new FileInputStream(file);
			DataInputStream dis = new DataInputStream(fis);
			BufferedReader br = new BufferedReader(new InputStreamReader(dis));
			long size = file.length();
			char[] buffer = new char[(int)size];
			br.read(buffer);
			strBfr.append(buffer);
			return strBfr.toString();
		} catch (IOException ex) {
			Logger.getLogger(IO.class.getName()).log(Level.SEVERE, null, ex);
		}
		return null;
	}
	
}
